#include "cardpanel.h"

#include <QPainter>



CardPanel::CardPanel(QWidget *parent)
    : QWidget{parent}
{

}

void CardPanel::Set_Image(const QPixmap &front, const QPixmap &back)
{
    front_ = front;
    back_ = back;

    setFixedSize(front_.size());
    update();
}

const QPixmap &CardPanel::Get_Image()const
{
    return front_;
}

void CardPanel::Set_Front_Or_Back_Side(bool falg)
{
    is_front_ = falg;
}

bool CardPanel::Is_Front_Side()
{
    return is_front_;
}

void CardPanel::Set_Selected(bool flag)
{
    is_selete_ = flag;
}

bool CardPanel::Is_Selected()
{
    return is_selete_;
}

void CardPanel::Set_Card(const Card &card)
{
    card_ = card;
}

const Card &CardPanel::Get_Card() const
{
    return card_;
}

void CardPanel::Set_Owner(Player *player)
{
    ower_ = player;
}

Player *CardPanel::Get_Owner()
{
    return ower_;
}

void CardPanel::paintEvent(QPaintEvent *event)
{
    QPainter p(this);
    if(is_front_)
    {
        p.drawPixmap(rect(),front_);
    }
    else
    {
        p.drawPixmap(rect(),back_);
    }
}

void CardPanel::mousePressEvent(QMouseEvent *event)
{

}
